package com.example.practical_training_projects.mapper;


import com.example.practical_training_projects.entity.appointment;
import com.example.practical_training_projects.vo.userappointment;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface appointmentMapper {
    @Insert("INSERT INTO appointment (user_name,pc_name,user_uid,pc_uid,ws_id,time,ws_date) " +
            "VALUES (#{user_name}, #{pc_name}, #{user_uid}, #{pc_uid}, #{ws_id}, #{time},#{ws_date})")
    Integer insertYuyue(appointment appointment1);

    @Select("SELECT user.user_phone, user.user_sex, appointment.user_name, appointment.ws_date, appointment.time,appointment.ws_id " +
            "FROM user " +
            "JOIN appointment ON user.user_uid = appointment.user_uid " +
            "WHERE appointment.pc_uid = #{pc_uid}")
    List<userappointment> pcselect(@Param("pc_uid") Integer pc_uid);

    @Select("SELECT pc.pc_phone,pc.picture,pc.pc_email,appointment.pc_name,appointment.user_uid,appointment.ws_date, appointment.ap_id,appointment.time,appointment.ws_id " +
            "FROM pc " +
            "JOIN appointment ON pc.pc_uid = appointment.pc_uid " +
            "WHERE appointment.user_uid = #{user_uid}")
    List<userappointment> userselectyuyue(@Param("user_uid") Integer user_uid);

    @Select("select * from appointment order by ws_date desc")
    List<appointment> admincheck();
  @Delete("delete  from appointment where ap_id = #{id}")
    Integer deleteAppointment(@Param("id") Integer id);
}
